home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / gnu / include / incl98.zoo / dirent.h < prev    next >
C/C++ Source or Header  |  1993-11-05  |  3KB  |  100 lines

  1. /* header file for POSIX directory access routines */
  2.  
  3. #ifndef _DIRENT_H
  4. #define _DIRENT_H
  5.  
  6. #ifndef _COMPILER_H
  7. #include <compiler.h>
  8. #endif
  9.  
  10. #ifndef _TYPES_H
  11. #include <types.h>
  12. #endif
  13.  
  14. #ifndef NAME_MAX
  15. # include <limits.h>
  16. #endif
  17.  
  18. #ifdef __MINT__
  19. # ifndef _OSTRUCT_H
  20. #  include <ostruct.h>
  21. # endif
  22. #endif
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. #ifndef _LIB_NAME_MAX
  29. #  define _LIB_NAME_MAX NAME_MAX
  30. #endif
  31.  
  32. struct dirent {
  33.        long            d_ino;          /* garbage under TOS */
  34.        off_t           d_off;          /* position in directory  */
  35.        short           d_reclen;       /* for us, length of d_name */
  36. #ifndef __MINT__
  37. /* the following (except for d_name) are unique to TOS */
  38.        struct dirent   *d_next;        /* ptr to next struct dirent in list */
  39.        unsigned char   d_attribute;    /* file modes from Fsfirst()  */
  40.        unsigned short  d_time, d_date; /* TOS date and time for file */
  41.        long            d_size;         /* file size */
  42.        char            d_name[1];
  43. #else
  44.        char            d_name[NAME_MAX+1];
  45. #endif
  46. };
  47.  
  48. #ifndef __MINT__
  49. typedef struct _DIR {
  50.        struct dirent *D_list;          /* list of directory entries */
  51.        struct dirent *D_curpos;        /* current position in list  */
  52.        char          *D_path;          /* path to this directory    */
  53.        struct _DIR   *D_nxtdir;        /* next DIR in opendir chain */
  54. } DIR;
  55.  
  56. #else
  57.  
  58. typedef struct _DIR {
  59.     short    status;        /* status of the search so far: */
  60. #define _INSEARCH    0    /* need to call Fsnext for a new entry */
  61. #define _STARTSEARCH    1    /* Fsfirst called once, successfully */
  62. #define _NMFILE        2    /* no more files in directory */
  63.     _DTA    dta;        /* TOS DTA for this directory */
  64.     char    *dirname;    /* directory of the search (used under
  65.                    TOS for rewinddir) */
  66.     struct dirent buf;    /* dirent struct for this directory */
  67.     long    handle;        /* Dreaddir handle */
  68. } DIR;
  69.  
  70. #endif /* __MINT__ */
  71.  
  72. #define __DIRENTSIZ(x) (sizeof(struct dirent) + (x) + 1)
  73.  
  74. /* allow BSD emulation via sys/dir.h */
  75.  
  76. #ifdef _SYS_DIR_H
  77. #define direct        dirent
  78. #define d_fileno    d_ino
  79. #define d_namlen    d_reclen
  80.  
  81. #define DIRSIZ(dp)     __DIRENTSIZ((dp)->d_namlen)
  82. #define MAXNAMLEN    _LIB_NAME_MAX
  83. #endif
  84.  
  85. __EXTERN DIR *        opendir    __PROTO((const char *dirname));
  86. __EXTERN struct dirent *readdir    __PROTO((DIR *dirp));
  87. __EXTERN void        rewinddir __PROTO((DIR *dirp));
  88. __EXTERN int        closedir  __PROTO((DIR *dirp));
  89. #ifndef _POSIX_SOURCE
  90. __EXTERN off_t    telldir    __PROTO((DIR *dirp));
  91. __EXTERN void    seekdir    __PROTO((DIR *dirp, off_t loc));
  92. __EXTERN int    alphasort __PROTO((struct dirent **, struct dirent **));
  93. #endif /* _POSIX_SOURCE */
  94.  
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98.  
  99. #endif /* _DIRENT_H */
  100.